{% extends "admin.html" %}
{% block content-area %}
<div class="card">
  <header class="card-header">
    <p class="card-header-title">
      Dataset
    </p>
    <a href="#" class="card-header-icon" aria-label="more options">
      <span class="icon">
        <i class="fas fa-angle-down" aria-hidden="true"></i>
      </span>
    </a>
  </header>
  <div class="card-content">
    <table class="table is-fullwidth is-hoverable">
      <thead>
        <tr>
          <th>#</th>
          <th>Text</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        {% for doc in object_list %}
        <tr>
          <td>{{ forloop.counter0|add:page_obj.start_index }}</td>
          <td>{{ doc.text|truncatechars:200 }}</td>
          <td>
            <p class="control">
              <button class="button is-text delete-document-button" data-delete-document-id="{{ doc.id }}">
                <span class="icon is-small">
                  <i class="fas fa-trash"></i>
                </span>
                <span>Delete</span>
              </button>
            </p>
          </td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
</div>

{% if is_paginated %}
<nav class="pagination is-left" role="navigation" aria-label="pagination">
  <ul class="pagination-list">
    {% if page_obj.number == 1 %}
    <li class="pagination-link" disabled><span>⇤</span></li>
    {% else %}
    <li>
      <a class="pagination-link" href="?page=1">⇤</a>
    </li>
    {% endif %}
    {% if page_obj.has_previous %}
    <li>
      <a class="pagination-link" href="?page={{ page_obj.previous_page_number }}">&laquo;</a>
    </li>
    {% else %}
    <li class="pagination-link" disabled><span>&laquo;</span></li>
    {% endif %}
    {% for i in paginator.page_range %}
    {% if page_obj.number == i %}
    <li>
      <a class="pagination-link is-current" aria-label="Goto page {{ i }}">{{ i }}</a>
    </li>
    {% elif i > page_obj.number|add:'-5' and i < page_obj.number|add:'5' %} <li>
      <a href="?page={{ i }}" class="pagination-link" aria-label="Goto page {{ i }}">{{ i }}</a>
      </li>
      {% endif %}
      {% endfor %}
      {% if page_obj.has_next %}
      <li>
        <a class="pagination-link" href="?page={{ page_obj.next_page_number }}">&raquo;</a>
      </li>
      {% else %}
      <li class="pagination-link" disabled><span>&raquo;</span></li>
      {% endif %}
      {% if page_obj.number == paginator.num_pages %}
      <li class="pagination-link" disabled><span>⇥</span></li>
      {% else %}
      <li>
        <a class="pagination-link" href="?page={{ paginator.num_pages }}">⇥</a>
      </li>
      {% endif %}
  </ul>
</nav>
{% endif %}
{% endblock %}
